// packageA/pages/report/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        timeRange: [
            { name: '今日', value: 'today' },
            { name: '昨日', value: 'yesterday' },
            { name: '最近7天', value: '7days' },
            { name: '最近30天', value: '30days' }
          ],
          timeIndex: 0,
          shopList: [
            { name: '全部门店', value: 'all' },
            { name: '南山店', value: 'nanshan' },
            { name: '福田店', value: 'futian' },
            { name: '龙华店', value: 'longhua' }
          ],
          shopIndex: 0,
          coreIndicators: [
            { name: '浏览人数', value: '78,698', change: '+15.9%', rise: true },
            { name: '下单人数', value: '23,456', change: '+8.2%', rise: true },
            { name: '订单数', value: '28,789', change: '+12.3%', rise: true },
            { name: '下单金额', value: '¥542,328', change: '+18.5%', rise: true },
            { name: '付款人数', value: '21,345', change: '+7.6%', rise: true },
            { name: '付款金额', value: '¥498,765', change: '+16.2%', rise: true }
          ],
          detailData: [
            { name: '浏览人数', today: '78,698', yesterday: '67,890', compare: '+15.9', rise: true },
            { name: '下单人数', today: '23,456', yesterday: '21,678', compare: '+8.2', rise: true },
            { name: '订单数', today: '28,789', yesterday: '25,634', compare: '+12.3', rise: true },
            { name: '下单件数', today: '56,789', yesterday: '49,876', compare: '+13.8', rise: true },
            { name: '有效订单数', today: '27,890', yesterday: '24,567', compare: '+13.5', rise: true },
            { name: '下单金额', today: '¥542,328', yesterday: '¥457,890', compare: '+18.5', rise: true },
            { name: '退款金额', today: '¥23,456', yesterday: '¥21,345', compare: '+9.9', rise: false },
            { name: '付款人数', today: '21,345', yesterday: '19,876', compare: '+7.6', rise: true },
            { name: '付款订单数', today: '26,789', yesterday: '23,456', compare: '+14.2', rise: true },
            { name: '付款件数', today: '52,345', yesterday: '45,678', compare: '+14.6', rise: true },
            { name: '付款金额', today: '¥498,765', yesterday: '¥429,876', compare: '+16.2', rise: true }
          ],
        topIndicators: [
            { icon: "/images/icon-people.png", title: "客流量(人)", value: 78698, change: "较昨日：15.9% ▲" },
            { icon: "/images/icon-money.png", title: "销售额(元)", value: 54232.78, change: "较昨日：15.9% ▲" },
            { icon: "/images/icon-convert.png", title: "转化率", value: "90%", change: "较昨日：15.9% ▲" },
            { icon: "/images/icon-avg.png", title: "客单价(元)", value: 138.63, change: "较昨日：15.9% ▲" },
            { icon: "/images/icon-avg.png", title: "客流单价(元)", value: 98.23, change: "较昨日：15.9% ▲" }
          ],
          ageData: {
            series: [
              { name: "20岁以下", value: 25 },
              { name: "20-30岁", value: 25 },
              { name: "30-40岁", value: 25 },
              { name: "40岁以上", value: 25 }
            ]
          },
          typeData: {
            series: [
              { name: "新客户", value: 35 },
              { name: "回购客户", value: 35 },
              { name: "会员客户", value: 30 }
            ]
          },
          genderData: {
            series: [
              { name: "男性", value: 42 },
              { name: "女性", value: 58 }
            ]
          },
          salesData: [
            { name: "南山店", value: 80000 },
            { name: "福田店", value: 70000 },
            { name: "龙华店", value: 60000 },
            { name: "龙岗店", value: 50000 },
            { name: "宝安店", value: 40000 }
          ],
          trafficData: [
            { name: "南山店", value: 80000 },
            { name: "福田店", value: 70000 },
            { name: "龙华店", value: 60000 },
            { name: "龙岗店", value: 50000 },
            { name: "宝安店", value: 40000 }
          ],
          inspectionData: {
            series: [
              { name: "着装问题", value: 25 },
              { name: "摆放成列", value: 25 },
              { name: "前厅卫生", value: 25 },
              { name: "柜台收纳", value: 25 }
            ]
          }
    },
    timeChange(e) {
        this.setData({ timeIndex: e.detail.value })
        this.loadData()
      },
    
      dateChange(e) {
        console.log('日期变更:', e.detail.value)
        this.loadData()
      },
    
      shopChange(e) {
        this.setData({ shopIndex: e.detail.value })
        this.loadData()
      },
    
      loadData() {
        // 实际开发中这里应该调用接口获取数据
        wx.showLoading({ title: '加载中' })
        setTimeout(() => {
          wx.hideLoading()
        }, 500)
      },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.loadData()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})